import { HashMap } from "../../api/struct/HashMap";
import { E_GameBaseAttr } from "../defs/com/E_GameBaseAttr";
import { CDMath, E_CDMath } from "../excel/CDMath";
import { E_CDMathx } from "../excel/CDMathx";


/**
 * 扩展-战斗数值
 */
export abstract class CEMath {

    /**最大觉醒 */
    private static readonly petWakeLevelMaxMap = new HashMap<number, number>();

    /**初始化 */
    public static init(): void {

    }


    /**
     * 获取最大觉醒等级
     * @param baseMathId 
     */
    public static getPetWakeLevelMax(baseMathId: number): number {
        const v = this.petWakeLevelMaxMap.get(baseMathId);
        if (v) {
            return v;
        }

        let wakeLevel = 0;
        for (; ; wakeLevel++) {
            if (!CDMath.getData(baseMathId + wakeLevel)) {
                wakeLevel--;
                break;
            }
        }
        this.petWakeLevelMaxMap.put(baseMathId, wakeLevel);

        return wakeLevel;
    }


    /**
     * 属性转化
     * @param idx 
     */
    public static getExcelTypeByGameAttrType(idx: E_GameBaseAttr): E_CDMath {
        switch (idx) {
            default: return 0;
            case E_GameBaseAttr.phyAtk: return E_CDMath.phyAtk;
            case E_GameBaseAttr.fireAtk: return E_CDMath.fireAtk;
            case E_GameBaseAttr.iceAtk: return E_CDMath.iceAtk;
            case E_GameBaseAttr.lightAtk: return E_CDMath.lightAtk;
            case E_GameBaseAttr.phyDef: return E_CDMath.phyDef;
            case E_GameBaseAttr.fireDef: return E_CDMath.fireDef;
            case E_GameBaseAttr.iceDef: return E_CDMath.iceDef;
            case E_GameBaseAttr.lightDef: return E_CDMath.lightDef;
            case E_GameBaseAttr.hp: return E_CDMath.hp;
            case E_GameBaseAttr.mana: return E_CDMath.mana;
            case E_GameBaseAttr.normalQuick: return E_CDMath.normalQuick;
            case E_GameBaseAttr.quick: return E_CDMath.quick;
            case E_GameBaseAttr.hit: return E_CDMath.hit;
            case E_GameBaseAttr.dribble: return E_CDMath.dribble;
            case E_GameBaseAttr.dodge: return E_CDMath.dodge;
            case E_GameBaseAttr.crit: return E_CDMath.crit;
            case E_GameBaseAttr.res: return E_CDMath.res;
            case E_GameBaseAttr.block: return E_CDMath.block;
            case E_GameBaseAttr.critDmg: return E_CDMath.critDmg;
            case E_GameBaseAttr.hpRegen: return E_CDMath.hpRegen;
            case E_GameBaseAttr.manaRegen: return E_CDMath.manaRegen;
            case E_GameBaseAttr.dribbleRegen: return E_CDMath.dribbleRegen;
            case E_GameBaseAttr.dodgeRegen: return E_CDMath.dodgeRegen;
            case E_GameBaseAttr.critRegen: return E_CDMath.critRegen;
            case E_GameBaseAttr.blockRegen: return E_CDMath.blockRegen;
            case E_GameBaseAttr.phyAtkPercent: return E_CDMath.phyAtkPercent;
            case E_GameBaseAttr.fireAtkPercent: return E_CDMath.fireAtkPercent;
            case E_GameBaseAttr.iceAtkPercent: return E_CDMath.iceAtkPercent;
            case E_GameBaseAttr.lightAtkPercent: return E_CDMath.lightAtkPercent;
            case E_GameBaseAttr.hpPercent: return E_CDMath.hpPercent;
            case E_GameBaseAttr.manaPercent: return E_CDMath.manaPercent;
            case E_GameBaseAttr.hpRegenPercent: return E_CDMath.hpRegenPercent;
            case E_GameBaseAttr.manaRegenPercent: return E_CDMath.manaRegenPercent;
            case E_GameBaseAttr.dribbleRegenPercent: return E_CDMath.dribbleRegenPercent;
            case E_GameBaseAttr.dodgeRegenPercent: return E_CDMath.dodgeRegenPercent;
            case E_GameBaseAttr.critRegenPercent: return E_CDMath.critRegenPercent;
            case E_GameBaseAttr.blockRegenPercent: return E_CDMath.blockRegenPercent;
        }
    }


    /**
    * 属性转化
    * @param idx 
    */
    public static getGameAttrTypeByExcelType(idx: E_CDMath): E_GameBaseAttr {
        switch (idx) {
            default: return E_GameBaseAttr.EnumCount;
            case E_CDMath.phyAtk: return E_GameBaseAttr.phyAtk;
            case E_CDMath.fireAtk: return E_GameBaseAttr.fireAtk;
            case E_CDMath.iceAtk: return E_GameBaseAttr.iceAtk;
            case E_CDMath.lightAtk: return E_GameBaseAttr.lightAtk;
            case E_CDMath.phyDef: return E_GameBaseAttr.phyDef;
            case E_CDMath.fireDef: return E_GameBaseAttr.fireDef;
            case E_CDMath.iceDef: return E_GameBaseAttr.iceDef;
            case E_CDMath.lightDef: return E_GameBaseAttr.lightDef;
            case E_CDMath.hp: return E_GameBaseAttr.hp;
            case E_CDMath.mana: return E_GameBaseAttr.mana;
            case E_CDMath.normalQuick: return E_GameBaseAttr.normalQuick;
            case E_CDMath.quick: return E_GameBaseAttr.quick;
            case E_CDMath.hit: return E_GameBaseAttr.hit;
            case E_CDMath.dribble: return E_GameBaseAttr.dribble;
            case E_CDMath.dodge: return E_GameBaseAttr.dodge;
            case E_CDMath.crit: return E_GameBaseAttr.crit;
            case E_CDMath.res: return E_GameBaseAttr.res;
            case E_CDMath.block: return E_GameBaseAttr.block;
            case E_CDMath.critDmg: return E_GameBaseAttr.critDmg;
            case E_CDMath.hpRegen: return E_GameBaseAttr.hpRegen;
            case E_CDMath.manaRegen: return E_GameBaseAttr.manaRegen;
            case E_CDMath.dribbleRegen: return E_GameBaseAttr.dribbleRegen;
            case E_CDMath.dodgeRegen: return E_GameBaseAttr.dodgeRegen;
            case E_CDMath.critRegen: return E_GameBaseAttr.critRegen;
            case E_CDMath.blockRegen: return E_GameBaseAttr.blockRegen;
            case E_CDMath.phyAtkPercent: return E_GameBaseAttr.phyAtkPercent;
            case E_CDMath.fireAtkPercent: return E_GameBaseAttr.fireAtkPercent;
            case E_CDMath.iceAtkPercent: return E_GameBaseAttr.iceAtkPercent;
            case E_CDMath.lightAtkPercent: return E_GameBaseAttr.lightAtkPercent;
            case E_CDMath.hpPercent: return E_GameBaseAttr.hpPercent;
            case E_CDMath.manaPercent: return E_GameBaseAttr.manaPercent;
            case E_CDMath.hpRegenPercent: return E_GameBaseAttr.hpRegenPercent;
            case E_CDMath.manaRegenPercent: return E_GameBaseAttr.manaRegenPercent;
            case E_CDMath.dribbleRegenPercent: return E_GameBaseAttr.dribbleRegenPercent;
            case E_CDMath.dodgeRegenPercent: return E_GameBaseAttr.dodgeRegenPercent;
            case E_CDMath.critRegenPercent: return E_GameBaseAttr.critRegenPercent;
            case E_CDMath.blockRegenPercent: return E_GameBaseAttr.blockRegenPercent;
        }
    }


    /**
     * 属性转化
     * @param idx 
     */
    public static getExcelTypeXXXByGameAttrType(idx: E_GameBaseAttr): E_CDMathx {
        switch (idx) {
            default: return 0;
            case E_GameBaseAttr.phyAtk: return E_CDMathx.phyAtk;
            case E_GameBaseAttr.fireAtk: return E_CDMathx.fireAtk;
            case E_GameBaseAttr.iceAtk: return E_CDMathx.iceAtk;
            case E_GameBaseAttr.lightAtk: return E_CDMathx.lightAtk;
            case E_GameBaseAttr.phyDef: return E_CDMathx.phyDef;
            case E_GameBaseAttr.fireDef: return E_CDMathx.fireDef;
            case E_GameBaseAttr.iceDef: return E_CDMathx.iceDef;
            case E_GameBaseAttr.lightDef: return E_CDMathx.lightDef;
            case E_GameBaseAttr.hp: return E_CDMathx.hp;
            case E_GameBaseAttr.mana: return E_CDMathx.mana;
            case E_GameBaseAttr.normalQuick: return E_CDMathx.normalQuick;
            case E_GameBaseAttr.quick: return E_CDMathx.quick;
            case E_GameBaseAttr.hit: return E_CDMathx.hit;
            case E_GameBaseAttr.dribble: return E_CDMathx.dribble;
            case E_GameBaseAttr.dodge: return E_CDMathx.dodge;
            case E_GameBaseAttr.crit: return E_CDMathx.crit;
            case E_GameBaseAttr.res: return E_CDMathx.res;
            case E_GameBaseAttr.block: return E_CDMathx.block;
            case E_GameBaseAttr.critDmg: return E_CDMathx.critDmg;
            case E_GameBaseAttr.hpRegen: return E_CDMathx.hpRegen;
            case E_GameBaseAttr.manaRegen: return E_CDMathx.manaRegen;
            case E_GameBaseAttr.dribbleRegen: return E_CDMathx.dribbleRegen;
            case E_GameBaseAttr.dodgeRegen: return E_CDMathx.dodgeRegen;
            case E_GameBaseAttr.critRegen: return E_CDMathx.critRegen;
            case E_GameBaseAttr.blockRegen: return E_CDMathx.blockRegen;
            case E_GameBaseAttr.phyAtkPercent: return E_CDMathx.phyAtkPercent;
            case E_GameBaseAttr.fireAtkPercent: return E_CDMathx.fireAtkPercent;
            case E_GameBaseAttr.iceAtkPercent: return E_CDMathx.iceAtkPercent;
            case E_GameBaseAttr.lightAtkPercent: return E_CDMathx.lightAtkPercent;
            case E_GameBaseAttr.hpPercent: return E_CDMathx.hpPercent;
            case E_GameBaseAttr.manaPercent: return E_CDMathx.manaPercent;
            case E_GameBaseAttr.hpRegenPercent: return E_CDMathx.hpRegenPercent;
            case E_GameBaseAttr.manaRegenPercent: return E_CDMathx.manaRegenPercent;
            case E_GameBaseAttr.dribbleRegenPercent: return E_CDMathx.dribbleRegenPercent;
            case E_GameBaseAttr.dodgeRegenPercent: return E_CDMathx.dodgeRegenPercent;
            case E_GameBaseAttr.critRegenPercent: return E_CDMathx.critRegenPercent;
            case E_GameBaseAttr.blockRegenPercent: return E_CDMathx.blockRegenPercent;
        }
    }


    /**
    * 属性转化
    * @param idx 
    */
    public static getGameAttrTypeByExcelTypeXXX(idx: E_CDMathx): E_GameBaseAttr {
        switch (idx) {
            default: return E_GameBaseAttr.EnumCount;
            case E_CDMathx.phyAtk: return E_GameBaseAttr.phyAtk;
            case E_CDMathx.fireAtk: return E_GameBaseAttr.fireAtk;
            case E_CDMathx.iceAtk: return E_GameBaseAttr.iceAtk;
            case E_CDMathx.lightAtk: return E_GameBaseAttr.lightAtk;
            case E_CDMathx.phyDef: return E_GameBaseAttr.phyDef;
            case E_CDMathx.fireDef: return E_GameBaseAttr.fireDef;
            case E_CDMathx.iceDef: return E_GameBaseAttr.iceDef;
            case E_CDMathx.lightDef: return E_GameBaseAttr.lightDef;
            case E_CDMathx.hp: return E_GameBaseAttr.hp;
            case E_CDMathx.mana: return E_GameBaseAttr.mana;
            case E_CDMathx.normalQuick: return E_GameBaseAttr.normalQuick;
            case E_CDMathx.quick: return E_GameBaseAttr.quick;
            case E_CDMathx.hit: return E_GameBaseAttr.hit;
            case E_CDMathx.dribble: return E_GameBaseAttr.dribble;
            case E_CDMathx.dodge: return E_GameBaseAttr.dodge;
            case E_CDMathx.crit: return E_GameBaseAttr.crit;
            case E_CDMathx.res: return E_GameBaseAttr.res;
            case E_CDMathx.block: return E_GameBaseAttr.block;
            case E_CDMathx.critDmg: return E_GameBaseAttr.critDmg;
            case E_CDMathx.hpRegen: return E_GameBaseAttr.hpRegen;
            case E_CDMathx.manaRegen: return E_GameBaseAttr.manaRegen;
            case E_CDMathx.dribbleRegen: return E_GameBaseAttr.dribbleRegen;
            case E_CDMathx.dodgeRegen: return E_GameBaseAttr.dodgeRegen;
            case E_CDMathx.critRegen: return E_GameBaseAttr.critRegen;
            case E_CDMathx.blockRegen: return E_GameBaseAttr.blockRegen;
            case E_CDMathx.phyAtkPercent: return E_GameBaseAttr.phyAtkPercent;
            case E_CDMathx.fireAtkPercent: return E_GameBaseAttr.fireAtkPercent;
            case E_CDMathx.iceAtkPercent: return E_GameBaseAttr.iceAtkPercent;
            case E_CDMathx.lightAtkPercent: return E_GameBaseAttr.lightAtkPercent;
            case E_CDMathx.hpPercent: return E_GameBaseAttr.hpPercent;
            case E_CDMathx.manaPercent: return E_GameBaseAttr.manaPercent;
            case E_CDMathx.hpRegenPercent: return E_GameBaseAttr.hpRegenPercent;
            case E_CDMathx.manaRegenPercent: return E_GameBaseAttr.manaRegenPercent;
            case E_CDMathx.dribbleRegenPercent: return E_GameBaseAttr.dribbleRegenPercent;
            case E_CDMathx.dodgeRegenPercent: return E_GameBaseAttr.dodgeRegenPercent;
            case E_CDMathx.critRegenPercent: return E_GameBaseAttr.critRegenPercent;
            case E_CDMathx.blockRegenPercent: return E_GameBaseAttr.blockRegenPercent;
        }
    }
}